﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.IO;
namespace WinFromMediaPlayerDemo
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainFrom());
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
        }

        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            using (FileStream fs = new FileStream(@".\log.txt", FileMode.Append))
            {
                string logContent = $"{DateTime.Now}{Environment.NewLine}";
                Exception exc = e.ExceptionObject as Exception;
                if(exc == null)
                {
                    logContent += "未知异常";
                }
                else
                {
                    logContent += $"{exc.Message}{Environment.NewLine}{exc.StackTrace}{Environment.NewLine}";
                }
                
            }
        }
    }
}
